<!DOCTYPE html>
<html>

	<head lang="en">
		<title>找攻略</title>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<link rel="stylesheet" href="/js/plugins/bootstrap-4.1.1-dist/css/bootstrap.min.css">
		<script src="/js/plugins/jquery/jquery.min.js"></script>
		<script src="/js/plugins/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
		<link rel="stylesheet" href="/css/font/css/font-awesome.min.css" />
		<link rel="stylesheet" href="/css/reset.css" />
		<link rel="stylesheet" href="/css/myStrategyComment.css" />
		<script src="/js/plugins/jrender/jrender.min.js"></script>
		<link rel="stylesheet" href="/js/plugins/jquery-confirm/css/jquery-confirm.css">
		<script src="/js/plugins/jquery-confirm/js/jquery-confirm.js"></script>
		<script src="/js/common.js"></script>
		<script src="/js/plugins/form/jquery.form.js"></script>
		<link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
		<script src="/js/plugins/dialog2/dialog.min.js"></script>
		<script>
			$(function () {
                var params = getParams();
			    //回显系统标签,让游客选取
				$.get('/tags/{state}',{state:0,strategyId:params.strategyId},function (data) {
					$.each(data,function (index,ele) {
                        $("#tag").append('<label class="btn btn-outline-danger "><input type="checkbox" autocomplete="off" value="'+ele.id+'" name="tag"> '+ele.name+'</label>')
                    })
                })

                if (params){
                    $("#strategy").val(params.strategyId)
                }
                //星星点评数量设置
                var starNum = 0;
			    //星星点评
				$('.comment i').click(function () {
                    starNum = 0;
                    var num = $(this).data("num");
                    $.each($('.comment i'),function (index,ele) {
                        if ( $(ele).data("num")<= num){
							$(ele).removeClass("fa-star-o")
                            $(ele).addClass("fa-star");
                        }
                        if ($(ele).data("num")>num) {
                            $(ele).removeClass("fa-star")
                            $(ele).addClass("fa-star-o");
						}
                    })
                    $.each($('.comment i'),function (index,ele) {
                        if ( $(ele).hasClass("fa-star")){
                            starNum++;
                        }
                    })
                    $("#starNum").val(starNum);
                })
				//点击事件,处理上传图片
				$('.col-3').click(function () {
                    $('#pic').click();
                })
                $('#pic').change(function () {
					if ($('#pic').val()){
					    $('#imgForm').ajaxSubmit(function (data){
                            if(data.status==1){
                                $('#col-3').before('<div class="col-3 rect"> <img id="headImg" src="'+data.url+'"/></div>');
								$('#addComment').append('<input type="hidden" value="'+data.url+'" name="imgUrls">')
							}
						})
					}
                })
				$('#submitBtn').click(function () {
                    $('#addComment').ajaxSubmit(function (data) {
						if (data.success){
                            $(document).dialog({
                                type: 'notice',
                                infoText: '评论成功!',
                                autoClose: 1500
                            });
                            window.parent.location.href = "/strategyCatalogs.html?strategyId="+params.strategyId;
						}
                    })
                })
            })
		</script>
	</head>

	<body>
	<div class="search-head">
		<div class="row nav-search">
			<div class="col">
				<a href="javascript:window.history.go(-1)">
					<span><i class="fa fa-chevron-left" ></i></span>
				</a>

			</div>
			<div class="col">
				<span>点评</span>
			</div>
			<div class="col"></div>
		</div>
	</div>

	<div class="comment">
		<div class="container star">
			<p>你对该旅游地的评价</p>
			<i class="fa fa-star-o fa-lg" data-num="1"></i>
			<i class="fa fa-star-o fa-lg" data-num="2"></i>
			<i class="fa fa-star-o fa-lg" data-num="3"></i>
			<i class="fa fa-star-o fa-lg" data-num="4"></i>
			<i class="fa fa-star-o fa-lg" data-num="5"></i>
		</div>
		<hr />
		<form method="post" action="/strategyComments" id="addComment">
			<!--星星点评星数-->
			<input type="hidden" value="0" name="starNum" id="starNum">
			<input type="hidden" name="strategy.id" id="strategy">
			<div class="container tag">
				<p>请为该旅游地选择合适的标签（大家都在评）</p>
				<div class="btn-group-toggle" data-toggle="buttons" id="tag">
				</div>

				<p>添加你自己的标签</p>
				<input name="myTags" class="form-control"  placeholder="请使用空格隔开标签，每个标签不超8个字"   />

				<p>更多评价内容</p>
				<textarea name="content" class="form-control" rows="5" placeholder="请填写你对该旅游地的评价"></textarea>
			</div>
		</form>
			<div class="container imgs ">
				<p>上传图片</p>

				<div class="row" id="imgs">
					<form id="imgForm" method="post" enctype="multipart/form-data" action="/images">
						<input type="file" style="display: none" name="file" id="pic"/>
					</form>

					<div class="col-3 rect" id="col-3">
						<span>上传</span>
					</div>
					
				</div>
			</div>
	</div>



	<div class="operation">
		<button class="btn" onclick="window.history.go(-1)">放弃评价</button>
		<button class="btn" id="submitBtn">提交评价</button>
	</div>





	</body>


</html>